home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
081-090
/
amok81
/
m2
/
talkdemo
/
txt
/
talknarrator.mod
< prev
next >
Wrap
Text File
|
1993-11-04
|
5KB
|
209 lines
IMPLEMENTATION MODULE TalkNarrator;
(*$ LargeVars:=FALSE StackParms:=FALSE Volatile:=FALSE
LongAlign:=TRUE
*)
FROM SYSTEM IMPORT ADR, ADDRESS, CAST, LONGSET, SHIFT;
FROM Arts IMPORT Assert,BreakPoint;
FROM ExecD IMPORT MsgPort, MsgPortPtr, IOStdReq, IOStdReqPtr, write,read,quick,
aborted;
FROM ExecL IMPORT WaitPort, DoIO, SendIO, GetMsg, ReplyMsg, OpenDevice,
CloseDevice,CreateMsgPort,DeleteMsgPort,CheckIO,
CreateIORequest,DeleteIORequest,WaitIO,AbortIO;
FROM GraphicsD IMPORT DrawModes,DrawModeSet;
FROM GraphicsL IMPORT SetAPen,SetBPen,Move,Draw,SetDrMd,PolyDraw,DrawEllipse;
FROM Narrator IMPORT NewNarrator, NewNarratorPtr, NewMouth, NewMouthPtr,
Mouth,noWrite,NarratorFlags,NarratorFlagSet;
FROM TalkErr IMPORT ShowErr;
IMPORT TranslatorL;
FROM String IMPORT Length;
IMPORT TB:TalkBase;
TYPE
Arr4=ARRAY[0..3] OF SHORTINT;
CONST
audChanMasks=Arr4{0011L,0101L,1010L,1100L};
VAR
(*$ LongAlign:=TRUE *)
actPhonBuff:TB.Str255;
readport,
writeport:MsgPortPtr;
narr:NewNarratorPtr;
readNarrator: NewMouthPtr;
(*$ LongAlign:=FALSE *)
oldb,
oldh:INTEGER;
first:=BOOLEAN{TRUE};
PROCEDURE DrawMouth(width{6},height{7}:INTEGER);
BEGIN
SetDrMd(TB.myRp,DrawModeSet{complement});
IF first THEN
first:=FALSE
ELSE (* alten Mund erst löschen *)
DrawEllipse(TB.myRp,TB.midX,TB.midY,oldb,oldh);
DrawEllipse(TB.myRp,TB.midX,TB.midY,oldb,oldh+2);
END;
oldb:=6*width; oldh:=height;
DrawEllipse(TB.myRp,TB.midX,TB.midY,oldb,oldh);
DrawEllipse(TB.myRp,TB.midX,TB.midY,oldb,oldh+2);
END DrawMouth;
PROCEDURE Translate():BOOLEAN;
BEGIN
RETURN TranslatorL.Translate(ADR(TB.textBuff),Length(TB.textBuff),
ADR(TB.phonBuff),SIZE(TB.phonBuff))=0;
END Translate;
PROCEDURE InitTalker;
BEGIN
actPhonBuff:=TB.phonBuff;
WITH narr^ DO
rate:=TB.myNarr.rate;
pitch:=TB.myNarr.pitch;
mode:=TB.myNarr.mode;
sex:=TB.myNarr.sex;
volume:=TB.myNarr.volume;
sampFreq:=TB.myNarr.sampFreq;
f0Enthusiasm:=TB.myNarr.f0Enthusiasm;
f0Perturb:=TB.myNarr.f0Perturb;
f1Adj:=TB.myNarr.f1Adj;
f2Adj:=TB.myNarr.f2Adj;
f3Adj:=TB.myNarr.f3Adj;
a1Adj:=TB.myNarr.a1Adj;
a2Adj:=TB.myNarr.a2Adj;
a3Adj:=TB.myNarr.a3Adj;
articulate:=TB.myNarr.articulate;
centralize:=TB.myNarr.centralize;
avBias:=TB.myNarr.avBias;
afBias:=TB.myNarr.afBias;
priority:=TB.myNarr.priority;
centphon:=TB.centLabs[ORD(TB.myNarr.centphon)];
END;
END InitTalker;
PROCEDURE ExtractNarr;
BEGIN
WITH narr^ DO
TB.myNarr.rate:=rate;
TB.myNarr.pitch:=pitch;
TB.myNarr.mode:=mode;
TB.myNarr.sex:=sex;
TB.myNarr.volume:=volume;
TB.myNarr.sampFreq:=sampFreq;
TB.myNarr.f0Enthusiasm:=f0Enthusiasm;
TB.myNarr.f0Perturb:=f0Perturb;
TB.myNarr.f1Adj:=f1Adj;
TB.myNarr.f2Adj:=f2Adj;
TB.myNarr.f3Adj:=f3Adj;
TB.myNarr.a1Adj:=a1Adj;
TB.myNarr.a2Adj:=a2Adj;
TB.myNarr.a3Adj:=a3Adj;
TB.myNarr.articulate:=articulate;
TB.myNarr.centralize:=centralize;
TB.myNarr.avBias:=avBias;
TB.myNarr.afBias:=afBias;
TB.myNarr.priority:=priority;
TB.myNarr.centphon:=MIN(TB.CentrPhons); (* !! *)
END;
END ExtractNarr;
PROCEDURE AbortTalk();
BEGIN
IF talking THEN
IF ~CheckIO(readNarrator) THEN
AbortIO(readNarrator);
END;
WaitIO(readNarrator);
IF ~CheckIO(narr) THEN
AbortIO(narr);
END;
WaitIO(narr);
IF narr^.message.error#aborted THEN
ShowErr(narr^.message.error);
END;
talking:=FALSE;
END;
END AbortTalk;
PROCEDURE DoTalk(testAbort:BoolProc);
BEGIN
talking:=TRUE;
InitTalker;
WITH narr^ DO
message.error:=0;
mouths:=1;
message.data:=ADR(actPhonBuff); message.length:=Length(actPhonBuff)
END;
WITH readNarrator^.voice.message DO
device:=narr^.message.device;
unit:=narr^.message.unit;
command:=read;
error:=0
END;
readNarrator^.width:=0; readNarrator^.height:=0;
SendIO(narr);
LOOP
IF narr^.message.error#0 THEN
EXIT;
END;
DoIO(readNarrator);
IF readNarrator^.voice.message.error#0 THEN EXIT END;
DrawMouth(readNarrator^.width,readNarrator^.height);
IF testAbort() THEN EXIT END;
END;
AbortTalk;
talking:=FALSE;
END DoTalk;
BEGIN
writeport:=CreateMsgPort();
readport:=CreateMsgPort();
narr:=CreateIORequest(writeport,SIZE(narr^));
readNarrator:=CreateIORequest(readport,SIZE(readNarrator^));
Assert((readNarrator#NIL) AND (narr#NIL),ADR("no CreatextIO"));
WITH narr^ DO
flags:=NarratorFlagSet{newIORB};
chMasks:=ADR(audChanMasks);
nmMasks:=SIZE(audChanMasks);
mouths:=1;
message.command:=write
END;
OpenDevice(ADR('narrator.device'),0,narr,LONGSET{});
ShowErr(narr^.message.error);
Assert(narr^.message.device#NIL,ADR('opendeverr'));
ExtractNarr;
TB.defNarr:=TB.myNarr;
DrawMouth(5,0);
CLOSE
AbortTalk;
IF narr#NIL THEN
WaitIO(narr);
CloseDevice(narr);
DeleteIORequest(narr);
narr:=NIL
END;
IF readNarrator#NIL THEN
DeleteIORequest(readNarrator);
readNarrator:=NIL
END;
IF readport#NIL THEN
DeleteMsgPort(readport);
readport:=NIL;
END;
IF writeport#NIL THEN
DeleteMsgPort(writeport);
writeport:=NIL
END;
END TalkNarrator.